﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Data;
using System.Globalization;
using SocialPlatformSDK.Model;
using SocialPlatformSDK.ViewModel;

namespace SocialPaltformSample
{
    public class StatusNameAndTextConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return string.Empty;
            }

            Status status = (value as Status);

            if (null == status)
            {
                return string.Empty;
            }

            return string.Format("{0}: {1}", status.Nick, status.Text);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public partial class Page2 : PhoneApplicationPage
    {
        private TimelineViewModel vm;
        public Page2()
        {
            InitializeComponent();
           

        }
        private void Refresh()
        {
            vm.Refresh(null);
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            Refresh();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            Refresh();
        }

        private void postNewButton_Click(object sender, EventArgs e)
        {
            //打开发送微博页面

        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (this.NavigationContext.QueryString.ContainsKey("name"))
            {
                string name = NavigationContext.QueryString["name"];
                vm = new TimelineViewModel(name);
                this.DataContext = vm;

            }

        }
    }



}